home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-16 | 5.3 KB | 194 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: CEServer.cpp
- // Release Version: $ ODF 3 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef CESERVER_H
- #include "CEServer.h"
- #endif
-
- #ifndef CEPRVGLU_H
- #include "CEPrvGlu.h"
- #endif
-
- #ifndef FWEXTMGR_H
- #include "FWExtMgr.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef CECLIENT_H
- #include "CEClient.h"
- #endif
-
- #ifndef __CODEFRAGMENTS__
- #include <CodeFragments.h>
- #endif
-
- //========================================================================================
- // Static Function Prototypes
- //========================================================================================
-
- static ODExtension* CE_CreateExtension(Environment* ev, FW_CPart* part, const char* name, void* refCon);
-
- FW_EXTERN_C_BEGIN
-
- static void CE_ForeColorProcGlue(Environment* ev, void* refCon, short red, short green, short blue);
- static void CE_BackColorProcGlue(Environment* ev, void* refCon, short red, short green, short blue);
-
- FW_EXTERN_C_END
-
- //========================================================================================
- // Static Allocations
- //========================================================================================
-
- static CE_SColorExtensionProcGlue gCallbackGlue = {CE_ForeColorProcGlue, CE_BackColorProcGlue};
-
- static ColorProc gForeColorProc;
- static ColorProc gBackColorProc;
-
- //========================================================================================
- // Public Functions
- //========================================================================================
-
-
- //----------------------------------------------------------------------------------------
- // CE_ExtensionLibraryExists
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CE_ExtensionLibraryExists()
- {
- return (&CE_OColorExtensionClassData != (void*)kUnresolvedCFragSymbolAddress);
- }
-
- //----------------------------------------------------------------------------------------
- // CE_SetCallbacks
- //----------------------------------------------------------------------------------------
-
- void CE_SetCallbacks(ColorProc foreColorProc, ColorProc backColorProc)
- {
- gForeColorProc = foreColorProc;
- gBackColorProc = backColorProc;
- }
-
- //----------------------------------------------------------------------------------------
- // CE_RegisterExtension
- //----------------------------------------------------------------------------------------
-
- void CE_RegisterExtension(Environment* ev, FW_CPart* part, void* refCon)
- {
- if (CE_ExtensionLibraryExists())
- {
- FW_CExtensionManager* extMgr = part->GetExtensionManager(ev);
- FW_ASSERT(extMgr);
-
- extMgr->RegisterExtension(ev, CE_kColorExtensionName, CE_CreateExtension, refCon, TRUE);
- }
- }
-
- //========================================================================================
- // Extension Creation Callback
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CE_CreateExtension
- //----------------------------------------------------------------------------------------
-
- ODExtension* CE_CreateExtension(Environment* ev,
- FW_CPart* part,
- const char* name,
- void* refCon)
- {
- FW_UNUSED(name);
- CE_OColorExtension* ce = new CE_OColorExtension;
- ce->InitColorExtension(ev, part->GetODPart(ev), refCon, &gCallbackGlue);
-
- return ce;
- }
-
- //========================================================================================
- // Callback Glue
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CE_ForeColorProcGlue
- //----------------------------------------------------------------------------------------
-
- void CE_ForeColorProcGlue(Environment* ev,
- void* refCon,
- short red,
- short green,
- short blue)
- {
-
- if (gForeColorProc)
- {
- FW_PlatformError error = FW_xNoError;
-
- FW_TRY
- {
- (gForeColorProc)(ev, refCon, red, green, blue);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- error = exception.GetPlatformError();
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE("Invalid exception caught in CE_ForeColorProcGlue");
- error = kODErrUndefined;
- }
- #endif
- FW_CATCH_END
-
- if (error != FW_xNoError)
- FW_SetEvError(ev, error);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CE_BackColorProcGlue
- //----------------------------------------------------------------------------------------
-
- void CE_BackColorProcGlue(Environment* ev,
- void* refCon,
- short red,
- short green,
- short blue)
- {
- if (gBackColorProc)
- {
- FW_PlatformError error = FW_xNoError;
-
- FW_TRY
- {
- (gBackColorProc)(ev, refCon, red, green, blue);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- error = exception.GetPlatformError();
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- FW_DEBUG_MESSAGE("Invalid exception caught in CE_ForeColorProcGlue");
- error = kODErrUndefined;
- }
- #endif
- FW_CATCH_END
-
- if (error != FW_xNoError)
- FW_SetEvError(ev, error);
- }
- }
-
-